function [ select_feature_index ] = FLD( class1,class2)
% fisher liner distinguesh of features
   [class1_samples_number, feature_number1] = size(class1);
   [class2_samples_number, feature_number2] = size(class2);
   if feature_number1 ~= feature_number2
        return
   end
   feature_number = feature_number1;
   % sample data
   samples = min(class1_samples_number, class2_samples_number);
   samples_class1 = class1(1 : samples, :);
   samples_class2 = class2(1 : samples, :);
   
   % mean data
   mean_class1 = repmat(mean(samples_class1), samples,1);
   mean_class2 = repmat(mean(samples_class2), samples,1);
   
   %centralized
   c_sample_class1 = samples_class1 - mean_class1;
   c_sample_class2 = samples_class2 - mean_class2;
   
   %select feature
   % max_rate = max(max_rate , add_rate, single)
   max_rate = 0;
   use_index = [];
   single_index = [];
   for index = [1:1:feature_number]
       % add rate
       tmp_index = [use_index index];
       len_index = length(tmp_index);
       class1_data = [];
       class2_data = [];
       for i = [1:1:len_index]
            class1_data = [class1_data c_sample_class1(: , tmp_index(i))];
            class2_data = [class2_data c_sample_class2(: , tmp_index(i))];
       end 
       s_b = sum(sum((class1_data - class2_data)'*(class1_data - class2_data)))';
       s_i = sum(sum((class1_data)'*(class1_data)))' + sum(sum((class2_data)'*(class2_data)))';
       a_rate = s_b / s_i;
       
       % single rate
       class1_data = c_sample_class1(: , index);
       class2_data = c_sample_class2(: , index);
       s_b = sum(sum((class1_data - class2_data)'*(class1_data - class2_data)))';
       s_i = sum(sum((class1_data)'*(class1_data)))' + sum(sum((class2_data)'*(class2_data)))';
       s_rate = s_b / s_i;
       if s_rate > 1
           single_index = [single_index index];
       end
           
       if s_rate > a_rate
           if s_rate > max_rate
               max_rate = s_rate;
               use_index = [index];
           end
       else
           if a_rate > max_rate
               max_rate = a_rate;
               use_index = [use_index index];
           end
       end  
       
        fprintf('\n %d %6f %6f %6f %d ',index,a_rate,s_rate,max_rate,use_index);
   end
   single_index
   select_feature_index = use_index;
end

